package com.dc.designPattern._23_specification.impl.step2;

import com.dc.designPattern._23_specification.impl.step2.spec.UserByAgeThan;
import com.dc.designPattern._23_specification.impl.step2.spec.UserByNameLike;
import com.google.common.collect.Lists;

import java.util.List;

/**
 * Description: 客户端
 * @author: gdc
 * @date: 2021/8/20
 * @version 1.0
 */
public class Client {

    public static void main(String[] args){
        List<User> userList = Lists.newArrayList();
        userList.add(new User("用户1", 1));
        userList.add(new User("用户2", 2));
        userList.add(new User("员工3", 3));
        userList.add(new User("员工4", 4));
        userList.add(new User("员工5", 5));
        userList.add(new User("员工6", 6));
        userList.add(new User("员工7", 7));
        userList.add(new User("用户8", 8));
        userList.add(new User("用户9", 9));
        userList.add(new User("用户10", 10));

        IUserProvider provider = new UserProvider(userList);
        System.out.println("==年龄大于6岁的用户==");
        provider.listByQuery(new UserByAgeThan(6)).forEach(System.out::println);

        System.out.println("------------------------------------");

        // 扩展新业务
        System.out.println("==名字包含用户的人员==");
        provider.listByQuery(new UserByNameLike("用户")).forEach(System.out::println);
    }

}
